{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "File has been downloaded to '/tmp/dataset/test.json'\n"
     ]
    }
   ],
   "source": [
    "# 普通minio文件路径\n",
    "import requests\n",
    "\n",
    "def download_file(url, local_path):\n",
    "    try:\n",
    "        # 发起 GET 请求下载文件\n",
    "        response = requests.get(url, stream=True)\n",
    "        response.raise_for_status()  # 检查请求是否成功\n",
    "\n",
    "        # 将文件内容写入本地文件\n",
    "        with open(local_path, 'wb') as file:\n",
    "            for chunk in response.iter_content(chunk_size=8192):\n",
    "                file.write(chunk)\n",
    "\n",
    "        print(f\"File has been downloaded to '{local_path}'\")\n",
    "    except requests.RequestException as e:\n",
    "        print(f\"An error occurred: {e}\")\n",
    "\n",
    "# 文件 URL 和保存路径\n",
    "file_url = 'http://192.168.1.9:9000/datalink/upload/20240516/b3b1fc4a011e50e68e08731014f82dc2.json'\n",
    "local_path = '/tmp/dataset/test.json'\n",
    "\n",
    "# 下载文件\n",
    "download_file(file_url, local_path)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}